﻿using iService;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Service;
using swiftCode.Bbs.Model.Model;


namespace swiftCode.Bbs.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ArticleController : ControllerBase
    {
        //使用构造方法注入依赖
        private readonly IArticleService _articleService;
        public ArticleController(IArticleService articleService)
        { 
            _articleService = articleService;
        }
        [HttpGet("{id}", Name = "Get")]
        public async Task<List<Article>> Get(int id)
        {
            //IArticleService articleService = new ArticleService();
            //return await _articleService.FindSingle(d => d.Id == id);
            return await _articleService.GetListAsync(d => d.Id == id);
        }
    }
}
